_helo = _this select 0;
_callsign = _this select 5;

//hint "test";
// hint format ["%1",_this];

_paytar = [];
RUM_ASclick = false;

// ========================================================================================
openMap [true,true];
for [{_n=1},{_n<=3},{_n=_n+1}] do {
	_mkrname = "";
	_type = "";
	_hint = "";
	switch (_n) do {
		case 1: {
			_mkrname = format ["%1target",_helo];
			_type = "Destroy";
			_hint = "Select Target Area for CAS";
		};
		case 2: {
			_mkrname = format ["%1ingress",_helo];
			_type = "mil_start";
			_hint = "Select Ingress Point";
		};
		case 3: {
			_mkrname = format ["%1egress",_helo];
			_type = "mil_end";
			_hint = "Select Egress Point";
		};
		default {
			hint "shit";	
		};
	};
	_asloc = createMarkerLocal [_mkrname, [0,0,0]];
	_asloc setMarkerShapeLocal "ICON";
	_mkrname setMarkerTypeLocal _type;
	_stgtar = "";
	if(_n == 1)then{_stgtar = format ["'%1' setMarkerPosLocal _pos,RUM_ASclick = [_pos] call ROEzone",_mkrname]}else{_stgtar = format ["'%1' setMarkerPosLocal _pos,RUM_ASclick = true",_mkrname]};	onMapSingleClick _stgtar;
	titleText [_hint, "PLAIN DOWN"];
	waitUntil {RUM_ASclick};
	onMapSingleClick "";
	if((_n == 2) or (_n == 3)) then {
		_mkrname2 = format ["%1target",_helo];
		_mkrname setMarkerDirLocal ((getMarkerPos _mkrname2 select 0)-(getMarkerPos _mkrname select 0)) atan2 ((getMarkerPos _mkrname2 select 1)-(getMarkerPos _mkrname select 1));
	};
	RUM_ASclick = false;
};
titleFadeOut 0;
sleep 1;
openMap [false,false];
// ==========================================================================================================
_station = format ["%1station",_helo];

_pilot = driver _helo;
_grp = group _pilot;
_mkrnamepri = format ["%1target",_helo];
_pos1 = getpos player;
_pos2 = getMarkerpos _mkrnamepri;
_dis = (round ((_pos2 distance _pos1)/10))*10;
_dir = round (((_pos2 select 0)-(_pos1 select 0)) atan2 ((_pos2 select 1)-(_pos1 select 1)));
if(_dir < 0)then{_dir = _dir + 360};

["5line",[player,_pilot,_callsign,_dir,_dis]] execVM (RUM_PATH+"AHel\radiodialogs.sqf");
sleep 26;

//
for [{_n=1},{_n<=4},{_n=_n+1}] do {
	_mkrname = "";
	switch (_n) do {
		case 1: {
			_mkrname = format ["%1ingress",_helo];
			[_mkrname,_grp] call RUM_AHel_MoveFromStation;
			[_mkrname,_grp] call RUM_AHel_movewaypoint;
			player sidechat"Case 1";
		};
		case 2: {
			_mkrname = format ["%1target",_helo];
			[_mkrname,_grp] call RUM_AHel_SAD;
			player sidechat"Case 2";
		};
		case 3: {
			_mkrname = format ["%1egress",_helo];
			[_mkrname,_grp] call RUM_AHel_movewaypoint;
			player sidechat"Case 3";
		};
		case 4: {
			_mkrname = format ["%1station",_helo];
			[_mkrname,_grp] call RUM_AHel_MoveToStation;
			player sidechat"Case 4";
		};
		default {
			hint "shit";	
		};
	};
};

_end = format ["%1",_helo];
sleep 5;
waitUntil{(!alive _helo) OR (RUM_AHel_endflight == _end)};
RUM_AHel_endflight = "";

_pilot sidechat format["This is %1, CAS mission completed. Returning back to stationed area...", _callsign ];
_helo doMove [ (getPos _helo select 0), (getPos _helo select 1), RUM_AHEL_flyStationHeight];
_helo flyInheight RUM_AHEL_flyStationHeight;
sleep 10;
waituntil{((getPos _helo select 2) <= (RUM_AHEL_flyStationHeight + 5))};
sleep 4;
_pilot sidechat format["This is %1, we are back on station and standing by for further orders.", _callsign ];

_mkrname1 = format ["%1ingress",_helo];
_mkrname2 = format ["%1target",_helo];
_mkrname3 = format ["%1egress",_helo];
deletemarkerLocal _mkrname1;
deletemarkerLocal _mkrname2;
deletemarkerLocal _mkrname3;

if(true)exitwith{};
